//
//  TimeChooseVc.m
//  sr01sdkProject
//
//  Created by   on 2022/5/27.
//

#import "TimeChooseVc.h"
#import "LZPTImePicker.h"
#import <Masonry/Masonry.h>
//#import <FQDateTimeSDK/FQDateTimeSDK.h>

@interface TimeChooseVc ()

@property(strong, nonatomic)UIButton *cancelBtn, *sureBtn;
//@property(strong, nonatomic)FQDateTimePickerView *pickView;

@property(strong, nonatomic)LZPTImePicker *timePicker;

@property(strong, nonatomic)NSNumber *curHor, *curMin, *curSec;

@end

@implementation TimeChooseVc

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColor.whiteColor;
    
    [self.view addSubview:self.sureBtn];
    [self.view addSubview:self.cancelBtn];
    
    [self.cancelBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.leading.top.equalTo(self.view);
        make.width.equalTo(@(60));
        make.height.equalTo(@44);
    }];
    
    [self.sureBtn  mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.trailing.top.equalTo(self.view);
        make.width.equalTo(@(60));
        make.height.equalTo(@44);
    }];
    
    [self.view addSubview:self.timePicker];
    [self.timePicker mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.equalTo(self.view);
        make.top.equalTo(self.sureBtn.mas_bottom).offset(20);
        make.height.equalTo(@200);
        
    }];
    
}

-(void)btnCLick:(UIButton *)sender {
    if (sender == self.sureBtn) {
        if (self.timeChoseCBK) {
            self.timeChoseCBK(self.curHor, self.curMin, self.curSec);
        }
    }
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}

-(UIButton *)cancelBtn
{
    if (!_cancelBtn) {
        _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_cancelBtn setTitleColor:UIColor.darkTextColor forState:normal];

        [_cancelBtn setTitle:@"Cancel" forState:UIControlStateNormal];
        [_cancelBtn addTarget:self action:@selector(btnCLick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cancelBtn;
}
-(UIButton *)sureBtn
{
    if (!_sureBtn) {
        _sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sureBtn setTitleColor:UIColor.darkTextColor forState:normal];
        [_sureBtn setTitle:@"Sure" forState:UIControlStateNormal];
        [_sureBtn addTarget:self action:@selector(btnCLick:) forControlEvents:UIControlEventTouchUpInside];

    }
    return _sureBtn;
}

-(UIPickerView *)timePicker
{
    if (!_timePicker) {
        _timePicker = [[LZPTImePicker alloc]init];
        __weak typeof(self) weakSlef = self;
        _timePicker.callBack = ^(NSNumber * _Nonnull hour, NSNumber * _Nonnull min, NSNumber * _Nonnull second) {
            __strong typeof(weakSlef) strongSelf = weakSlef;
            
            strongSelf.curHor = hour;
            strongSelf.curMin = min;
            strongSelf.curSec = second;
        };
    }
    
    return _timePicker;
}





@end
